//
//  ViewController.m
//  selectPhoto
//
//  Created by chenqiao on 16/6/12.
//  Copyright © 2016年 qiao. All rights reserved.
//

#import "ViewController.h"
#import "UIViewController+XHPhoto.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.title = @"照片选取";
    
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(100, 200, [[UIScreen mainScreen] bounds].size.width/2 - 20 , [[UIScreen mainScreen] bounds].size.width/2 - 20);
    button.clipsToBounds = YES;
    button.layer.cornerRadius = 2;
    [button setTitle:@"选择照片" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:12];
    button.backgroundColor = [UIColor cyanColor];
    [button addTarget:self action:@selector(selectPhoto:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}


-(void)selectPhoto:(UIButton *) sender
{
    /*
     edit:照片需要裁剪:传YES,不需要裁剪传NO(默认NO)
     */
    [self showCanEdit:YES photo:^(UIImage *photo) {
        [sender setBackgroundImage:photo forState:UIControlStateNormal];
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
